package com.zbkj.front.controller.user;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.MonitorOrderFrontSaveRequest;
import com.zbkj.common.request.MonitorOrderSearchRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.response.MonitorOrderFrontSearchResponse;
import com.zbkj.common.response.OrderNoResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.MonitorOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 监控订单 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/front/monitor/order")
@Api(tags = "监控订单控制器", description = "商户入驻充值监控订单表") //配合swagger使用

public class MonitorOrderController {

    @Autowired
    private MonitorOrderService monitorOrderService;

    /**
     * 分页显示监控订单表
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     * @author dazongzi
     * @since 2025-06-26
     */
//    @PreAuthorize("hasAuthority('platform:activitystyle:list')")
    @ApiOperation(value = "分页列表") //配合swagger使用
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<MonitorOrderFrontSearchResponse>> getList(@Validated MonitorOrderSearchRequest request,
                                                                             @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<MonitorOrderFrontSearchResponse> monitorOrderCommonPage = CommonPage.restPage(monitorOrderService.getListFront(request, pageParamRequest));
        return CommonResult.success(monitorOrderCommonPage);
    }

    @ApiOperation(value = "创建订单")
    @RequestMapping(value = "/user/create", method = RequestMethod.POST)
    public CommonResult<OrderNoResponse> createOrder(@RequestBody @Validated MonitorOrderFrontSaveRequest request) {
        return CommonResult.success(monitorOrderService.createOrder(request));
    }

}



